<?php
require_once 'glob.php';
if($_REQUEST['page']==""||$_REQUEST['page']==null)
{
	$page=1;
}else {
	$page=$_REQUEST['page'];
}
switch ($_REQUEST['action']) {
	case 'list':
		/*
		$xueniao->assign('infoclasslist',get_listarr('sn_infoclass'));
		$xueniao->display('infoclass_list.htm');
		*/
		
		get_list('sn_infoclass', array( id,name,ordid,isshow),'infoclasslist','infoclass_list.htm','fypage',$page,'where upid = 0 and isdel="N" order by ordid','?action=list&');


		break;

	case 'add':
		$xueniao->assign('infoclassup',get_clslist('sn_infoclass','无上级','0'));
		$xueniao->display('infoclass_info.htm');
		break;
	case 'insert':
		if($_REQUEST['fm_name']!=="")
		{
			$post=array(
			name=>$_REQUEST['fm_name'],
			upid=>$_REQUEST['fm_upid'],
			isshow=>$_REQUEST['fm_isshow'],
			ordid=>$_REQUEST['fm_ordid']
			);
			$res=$db->insert('sn_infoclass',$post);
			if($res==true){
				sys_msg('文章分类添加成功',0);
			}
		}
		break;
	case 'edit':
		if($_REQUEST['id']=="" || $_REQUEST['id']==null)
		{
			sys_msg('未指定信息分类,无法修改', 1);
			exit();
		}else {
			$fm_id=$_REQUEST['id'];
		}
		$xueniao->assign('infoclassup',get_clslist('sn_infoclass','无上级','0'));
		get_info('sn_infoclass', 'id,name,ordid,isshow,upid', 'infoclassinfo', 'infoclass_info.htm','id = '.$fm_id);
		break;
	case 'update':
		if($_REQUEST['id']=="" || $_REQUEST['id']==null)
		{
			sys_msg('未指定信息分类,无法修改', 1);
			exit();
		}else {
			$fm_id=$_REQUEST['id'];
		}
		$post=array(
		id=>$fm_id,
		//要更改的id
		name=>$_REQUEST['fm_name'],
		upid=>$_REQUEST['fm_upid'],
		isshow=>$_REQUEST['fm_isshow'],
		ordid=>$_REQUEST['fm_ordid']
		);

		$res=$db->update('sn_infoclass',$post,id);

		if($res==true){
			sys_msg('信息类别修改成功！',0);
		}

		break;
	default:
		get_list('sn_infoclass', array( id,name,ordid,isshow),'infoclasslist','infoclass_list.htm','fypage',$page,'where upid = 0 and isdel="N" order by ordid','?action=list&');
		break;
}